﻿using System;
using System.Collections;
using System.Dynamic;
using System.Runtime.CompilerServices;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortedList = new SortedList();
            sortedList.Add(3, "雪");
            sortedList.Add(2, "花");
            sortedList.Add(1, "风");
            sortedList.Add(4, "月");
            //判断
            Console.WriteLine("请输入:");
            int id = int.Parse(Console.ReadLine());
            bool a = sortedList.ContainsKey(id);
            if (a)
            {
                string name = sortedList[id].ToString();
                Console.WriteLine("找到的结果是:{0}",name);
            }
            else
            {
                Console.WriteLine("找不到");
            }
            //遍历
            foreach (DictionaryEntry list in sortedList)
            {
                Console.WriteLine("{0}   {1}", list.Key, list.Value);
            }
            //移除
            sortedList.Remove(1);
            foreach (DictionaryEntry list in sortedList)
            {
                Console.WriteLine("{0}   {1}", list.Key, list.Value);
            }
            //查找
            Console.WriteLine(sortedList.IndexOfKey(1));
            Console.WriteLine(sortedList.IndexOfValue("月"));
            //清除
            sortedList.Clear();
        }
    }
}
